#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;

void renjifight(){
	double player_a_health=100,player_b_health=100,player_a_power=100,player_b_power=100;
	int inputa,inputb;
	int ajiu=100,bjiu=100;
	double huixie,ps,ls;
	while(1+1==2){
		huixie=rand()%(30-1+1)+5;
		ps=rand()%(10-5+1)+5;
		ls=rand()%(18-13+1)+13;
		cout<<"===玩家的回合==="<<endl;
		cout<<"血量："<<player_a_health<<endl<<"体力："<<player_a_power<<endl; 
		cout<<"请选择操作：\n1.普通攻击\n2.连招\n3.大招\n4.闪避\n5.喝酒\n";
		do{
			cin>>inputa;
		}while(inputa!=1&&inputa!=2&&inputa!=3&&inputa!=4&&inputa!=5);
		if(inputa==1){
			player_b_health-=ps;
			player_a_power-=5; 
			cout<<"对对手造成了"<<ps<<"点伤害\n"; 
		}else if(inputa==2){
			player_b_health-=ls;
			player_a_power-=10;
			cout<<"对对手造成了"<<ls<<"点伤害\n"; 
		}else if(inputa==3){
			player_b_health-=30;
			player_a_power-=25;
			cout<<"对对手造成了30点伤害\n"; 
		}else if(inputa==4){
			player_a_health+=huixie;
			player_a_power+=5;
			cout<<"减免了"<<huixie<<"点伤害，恢复了5点体力\n"; 
		}else if(inputa==5&&ajiu>=0){
			player_a_power+=10;
			player_a_health+=10;
			cout<<"恢复了10点体力，10点血量\n" ;
			ajiu-=10;
			cout<<"还剩"<<ajiu<<endl;
		}
		cout<<"===对手的回合==="<<endl;
		cout<<"血量："<<player_b_health<<endl<<"体力："<<player_b_power<<endl; 
		srand(time(0));
		int enemyattack=rand()%(5-1+1)+1;
		if(enemyattack==1){
			player_a_health-=ps;
			player_b_power-=5; 
			cout<<"对玩家造成了"<<ps<<"点伤害\n"; 
		}else if(enemyattack==2){
			player_a_health-=ls;
			player_b_power-=10;
			cout<<"对玩家造成了"<<ls<<"点伤害\n"; 
		}else if(enemyattack==3){
			player_a_health-=30;
			player_b_power-=25;
			cout<<"对玩家造成了30点伤害\n"; 
		}else if(enemyattack==4){
			player_b_health+=huixie;
			player_b_power+=5;
			cout<<"减免了"<<huixie<<"点伤害，恢复了5点体力\n"; 
		}
		if(player_b_health<=0||player_b_power<=0){
			cout<<"玩家胜利！";
			break;
		}else if(player_a_health<=0||player_a_power<=0){
			cout<<"你死了！";
		}
	}
}

void pvpfight(){
	double player_a_health=100,player_b_health=100,player_a_power=100,player_b_power=100;
	int inputa,inputb;
	int ajiu=100,bjiu=100;
	double huixie,ps,ls;
	while(1+1==2){
		huixie=rand()%(30-1+1)+5;
		ps=rand()%(10-5+1)+5;
		ls=rand()%(18-13+1)+13;
		cout<<"===玩家A的回合==="<<endl;
		cout<<"血量："<<player_a_health<<endl<<"体力："<<player_a_power<<endl; 
		cout<<"请选择操作：\n1.普通攻击\n2.连招\n3.大招\n4.闪避\n5.喝酒\n";
		do{
			cin>>inputa;
		}while(inputa!=1&&inputa!=2&&inputa!=3&&inputa!=4&&inputa!=5);
		if(inputa==1){
			player_b_health-=ps;
			player_a_power-=5; 
			cout<<"对玩家B造成了"<<ps<<"点伤害\n"; 
		}else if(inputa==2){
			player_b_health-=ls;
			player_a_power-=10;
			cout<<"对玩家B造成了"<<ls<<"点伤害\n"; 
		}else if(inputa==3){
			player_b_health-=30;
			player_a_power-=25;
			cout<<"对玩家B造成了30点伤害\n"; 
		}else if(inputa==4){
			player_a_health+=huixie;
			player_a_power+=5;
			cout<<"减免了"<<huixie<<"点伤害，恢复了5点体力\n"; 
		}else if(inputa==5&&ajiu>=0){
			player_a_power+=10;
			player_a_health+=10;
			cout<<"恢复了10点体力，10点血量\n" ;
			ajiu-=10;
			cout<<"还剩"<<ajiu<<endl;
		}
		cout<<"===玩家B的回合==="<<endl;
		cout<<"血量："<<player_b_health<<endl<<"体力："<<player_b_power<<endl; 
		cout<<"请选择操作：\n1.普通攻击\n2.连招\n3.大招\n4.闪避\n5.喝酒\n";
		do{
			cin>>inputa;
		}while(inputa!=1&&inputa!=2&&inputa!=3&&inputa!=4&&inputa!=5);
		if(inputa==1){
			player_a_health-=ps;
			player_b_power-=5;
			cout<<"对玩家A造成了"<<ps<<"点伤害\n"; 
		}else if(inputa==2){
			player_a_health-=ls;
			player_b_power-=10;
			cout<<"对玩家A造成了"<<ls<<"点伤害\n"; 
		}else if(inputa==3){
			player_a_health-=30;
			player_b_power-=25;
			cout<<"对玩家B造成了30点伤害\n"; 
		}else if(inputa==4){
			player_b_health+=huixie;
			player_b_power+=5;
			cout<<"减免了"<<huixie<<"点伤害，恢复了5点体力\n"; 
		}else if(inputa==5&&bjiu>=0){
			player_b_power+=10;
			player_a_health+=10;
			cout<<"恢复了10点体力，10点血量\n";
			bjiu-=10;
			cout<<"还剩"<<bjiu<<endl; 
		}
		if(player_a_health==0){
			cout<<"玩家B胜利！";
			break; 
		}
		if(player_b_health==0){
			cout<<"玩家A胜利！"; 
			break;
		}
		if(player_a_power==0){
			cout<<"玩家B胜利！";
			break; 
		}
		if(player_b_power==0){
			cout<<"玩家A胜利！"; 
			break;
		}
	}
}
void gameloop(){
	cout<<"选择模式：\n1.人机对战\n2.真人对战\n3.退出\n";
	int i;
	do{
		cin>>i;
	}while(i!=1&&i!=2&&i!=3);
	if(i==1){
		renjifight();
		gameloop();
	}else if(i==2){
		pvpfight();
		gameloop();
	}else if(i==3){
		 
	}
	
}
int main(){
	srand(time(0));
	gameloop();
	return 0;
}